package com.azt.api.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 项目需求状态
 * @author 张栋  2016年5月6日下午4:57:24
 */
public enum EnquiryProstateEnum {

	/*项目需求状态 -1:保存,0:待审核,1:已发布,2:退回修改,3:重新审核 */
	/*项目需求状态 -1:全部,0:待审核,1:已发布,2:退回修改,3:重新审核*/
	PROSTATE_ALL(-1, "全部"), PROSTATE_STAY(0, "待审核"),PROSTATE_POSTED(1,"进行中"), PROSTATE_BACK(2, "退回修改"), PROSTATE_RETRY(3, "重新审核");

	private int index;
	private String title;

	private static List<EnquiryProstateEnum>  PROSTATELIST = null;
	private static Map<String,String>  PROSTATEMAP=null;
	
 	private EnquiryProstateEnum(int index, String title) {
		this.index = index;
		this.title = title;
	}
	
 	
 	/**获取列表
 	 * @return
 	 * @author 张栋  2016年5月16日下午1:47:23
 	 */
 	public static List<EnquiryProstateEnum> getStateList(){
 		if(PROSTATELIST == null ){
 			EnquiryProstateEnum[] values = EnquiryProstateEnum.values();
 			PROSTATELIST = Arrays.asList(values);
 		}
 		return PROSTATELIST;
 	}
 	
	/**
	 * 获取所有状态
	 * code ,title 
	 * @return
	 */
	public static Map<String, String> getAllStates(){
		if(PROSTATEMAP == null ){
			Map<String, String>  allroles = new HashMap<String,String>();
			EnquiryProstateEnum[] values = EnquiryProstateEnum.values();
			for (EnquiryProstateEnum c :values ) {
				allroles.put(c.getIndex()+"", c.getTitle());
			}
			PROSTATEMAP= allroles;
		}
		return PROSTATEMAP;
	}
	
	public static String getTitleByIndex(int index) {
		for (EnquiryProstateEnum c : EnquiryProstateEnum.values()) {
			if (c.getIndex() == index) {
				return c.title;
			}
		}
		return null;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	
}
